home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 118 / cd-rom 118.iso / aplic / open / openofficeorg2.cab / ooo2wordml_border.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-01-31  |  11.6 KB  |  180 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.    The Contents of this file are made available subject to the terms of
  4.    either of the following licenses
  5.  
  6.           - GNU Lesser General Public License Version 2.1
  7.           - Sun Industry Standards Source License Version 1.1
  8.  
  9.    Sun Microsystems Inc., October, 2000
  10.  
  11.    GNU Lesser General Public License Version 2.1
  12.    =============================================
  13.    Copyright 2000 by Sun Microsystems, Inc.
  14.    901 San Antonio Road, Palo Alto, CA 94303, USA
  15.  
  16.    This library is free software; you can redistribute it and/or
  17.    modify it under the terms of the GNU Lesser General Public
  18.    License version 2.1, as published by the Free Software Foundation.
  19.  
  20.    This library is distributed in the hope that it will be useful,
  21.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  23.    Lesser General Public License for more details.
  24.  
  25.    You should have received a copy of the GNU Lesser General Public
  26.    License along with this library; if not, write to the Free Software
  27.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  28.    MA  02111-1307  USA
  29.  
  30.  
  31.    Sun Industry Standards Source License Version 1.1
  32.    =================================================
  33.    The contents of this file are subject to the Sun Industry Standards
  34.    Source License Version 1.1 (the "License"); You may not use this file
  35.    except in compliance with the License. You may obtain a copy of the
  36.    License at http://www.openoffice.org/license.html.
  37.  
  38.    Software provided under this License is provided on an "AS IS" basis,
  39.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  40.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  41.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  42.    See the License for the specific provisions governing your rights and
  43.    obligations concerning the Software.
  44.  
  45.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  46.  
  47.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  48.  
  49.    All Rights Reserved.
  50.  
  51.    Contributor(s): _______________________________________
  52.    
  53.  -->
  54. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="office table style text draw svg   dc config xlink meta oooc dom ooo chart math dr3d form script ooow draw">
  55.     <!-- multiple usage: get size, type, color of table-cell, paragraph, and page borders. -->
  56.     <xsl:template name="get-border-size">
  57.         <xsl:param name="border"/>
  58.         <xsl:param name="border-line-width"/>
  59.         <xsl:choose>
  60.             <xsl:when test="$border = 'none' or $border = 'hidden'">
  61.                 <xsl:text>none;0</xsl:text>
  62.             </xsl:when>
  63.             <xsl:otherwise>
  64.                 <xsl:variable name="border-value">
  65.                     <xsl:call-template name="convert2cm">
  66.                         <xsl:with-param name="value" select="$border"/>
  67.                     </xsl:call-template>
  68.                 </xsl:variable>
  69.                 <xsl:variable name="border-style">
  70.                     <xsl:choose>
  71.                         <xsl:when test="contains($border,'solid')">solid</xsl:when>
  72.                         <xsl:when test="contains($border,'double')">double</xsl:when>
  73.                         <xsl:otherwise>none</xsl:otherwise>
  74.                     </xsl:choose>
  75.                 </xsl:variable>
  76.                 <!-- MS word and SO wirter borders Mapping
  77.                 MS word Borders                         SO borders
  78.                 w:val="single" w:sz="0"                     0.05pt(0.002cm);solid
  79.                 w:val="single" w:sz="12"                     1.00pt(0.035cm);solid
  80.                 w:val="single" w:sz="18"                      2.50pt(0.088cm);solid
  81.                 w:val="single" w:sz="36"                         4.00pt(0.141cm);solid
  82.                 w:val="single" w:sz="48"                          5.00pt(0.176cm);solid
  83.                 w:val="double" w:sz="2"                          1.10pt(0.039cm);double
  84.                 w:val="double" w:sz="6"                          2.60pt(0.092cm);double
  85.                 w:val="thin-thick-small-gap" w:sz="12"                  3.00pt(0.105cm);double
  86.                 w:val="thin-thick-large-gap" w:sz="18"                3.55pt(0.125cm);double
  87.                 w:val="thick-thin-medium-gap" w:sz="24"         4.50pt(0.158cm);double
  88.                 w:val="thin-thick-medium-gap" w:sz="24"         5.05pt(0.178cm);double
  89.                 w:val="thin-thick-small-gap" w:sz="24"            6.00pt(0.211cm);double
  90.                 w:val="thin-thick-medium-gap" w:sz="36            " 6.55pt(0.231cm);double
  91.                 w:val="double" w:sz="18"                         7.50pt(0.264cm);double
  92.                 w:val="thin-thick-medium-gap" w:sz="48"         9.00pt(0.317cm);double;style:border-line-width="0.088cm 0.088cm 0.141cm"
  93.                 w:val="double" w:sz="24"                        9.00pt(0.317cm);double;style:border-line-width="0.141cm 0.088cm 0.088cm" 
  94.                 we adjust the criteria by adding about 1/2 range of this current criteria and next criteria.  Gary. Yang -->
  95.                 <xsl:variable name="microsoft-border-style-size">
  96.                     <xsl:choose>
  97.                         <xsl:when test=" $border-style = 'solid'">
  98.                             <xsl:choose>
  99.                                 <xsl:when test="$border-value <= 0.018">single;0</xsl:when>
  100.                                 <xsl:when test="$border-value <= 0.055">single;12</xsl:when>
  101.                                 <xsl:when test="$border-value <= 0.110">single;18</xsl:when>
  102.                                 <xsl:when test="$border-value <= 0.155">single;36</xsl:when>
  103.                                 <xsl:when test="$border-value <= 0.198">single;48</xsl:when>
  104.                                 <xsl:otherwise>single;48</xsl:otherwise>
  105.                             </xsl:choose>
  106.                         </xsl:when>
  107.                         <xsl:when test="$border-style = 'double'">
  108.                             <xsl:choose>
  109.                                 <xsl:when test="$border-value < 0.064">double;2</xsl:when>
  110.                                 <xsl:when test="$border-value < 0.098">double;6</xsl:when>
  111.                                 <xsl:when test="$border-value < 0.115">thin-thick-small-gap;12</xsl:when>
  112.                                 <xsl:when test="$border-value < 0.135">thin-thick-large-gap;18</xsl:when>
  113.                                 <xsl:when test="$border-value < 0.168">thick-thin-medium-gap;24</xsl:when>
  114.                                 <xsl:when test="$border-value < 0.190">thin-thick-medium-gap;24</xsl:when>
  115.                                 <xsl:when test="$border-value < 0.221">thin-thick-small-gap;24</xsl:when>
  116.                                 <xsl:when test="$border-value < 0.241">thin-thick-medium-gap;36</xsl:when>
  117.                                 <xsl:when test="$border-value < 0.300">double;18</xsl:when>
  118.                                 <xsl:when test="$border-value < 0.430">
  119.                                     <xsl:variable name="border-inner-line-value">
  120.                                         <xsl:call-template name="convert2cm">
  121.                                             <xsl:with-param name="value" select="$border-line-width"/>
  122.                                         </xsl:call-template>
  123.                                     </xsl:variable>
  124.                                     <xsl:if test="$border-inner-line-value < 0.10">thin-thick-medium-gap;48</xsl:if>
  125.                                     <xsl:if test="$border-inner-line-value > 0.10">double;24</xsl:if>
  126.                                 </xsl:when>
  127.                                 <xsl:otherwise>double;24</xsl:otherwise>
  128.                             </xsl:choose>
  129.                         </xsl:when>
  130.                         <xsl:otherwise>none;0</xsl:otherwise>
  131.                     </xsl:choose>
  132.                 </xsl:variable>
  133.                 <xsl:value-of select="$microsoft-border-style-size"/>
  134.             </xsl:otherwise>
  135.         </xsl:choose>
  136.     </xsl:template>
  137.     <!-- get bottom and right border style, size, color  -->
  138.     <xsl:template name="get-border">
  139.         <xsl:param name="so-border"/>
  140.         <xsl:param name="so-border-line-width"/>
  141.         <xsl:param name="so-border-position"/>
  142.         <xsl:variable name="ms-style-width">
  143.             <xsl:call-template name="get-border-size">
  144.                 <xsl:with-param name="border" select="$so-border"/>
  145.                 <xsl:with-param name="border-line-width" select="$so-border-line-width"/>
  146.             </xsl:call-template>
  147.         </xsl:variable>
  148.         <xsl:choose>
  149.             <xsl:when test="$so-border-position = 'bottom' or $so-border-position = 'right'">
  150.                 <!-- if border style is bottom or right border we need to change the thin-thick to thick-thin; Vice Versa -->
  151.                 <xsl:choose>
  152.                     <xsl:when test="substring-before($ms-style-width, '-')='thin'">
  153.                         <xsl:attribute name="w:val"><xsl:value-of select="concat( 'thick-thin', substring-after(substring-before($ms-style-width, ';'), 'k' ))"/></xsl:attribute>
  154.                     </xsl:when>
  155.                     <xsl:when test="substring-before($ms-style-width, '-')='thick'">
  156.                         <xsl:attribute name="w:val"><xsl:value-of select="concat( 'thin-thick', substring-after(substring-before($ms-style-width, ';'), 'n' ))"/></xsl:attribute>
  157.                     </xsl:when>
  158.                     <xsl:otherwise>
  159.                         <xsl:attribute name="w:val"><xsl:value-of select="substring-before($ms-style-width, ';')"/></xsl:attribute>
  160.                     </xsl:otherwise>
  161.                 </xsl:choose>
  162.                 <xsl:attribute name="w:sz"><xsl:value-of select="substring-after($ms-style-width,';')"/></xsl:attribute>
  163.             </xsl:when>
  164.             <xsl:when test="$so-border-position = 'top' or $so-border-position = 'left'">
  165.                 <xsl:attribute name="w:val"><xsl:value-of select="substring-before($ms-style-width,';')"/></xsl:attribute>
  166.                 <xsl:attribute name="w:sz"><xsl:value-of select="substring-after($ms-style-width,';')"/></xsl:attribute>
  167.             </xsl:when>
  168.         </xsl:choose>
  169.         <!--get border color -->
  170.         <xsl:choose>
  171.             <xsl:when test="contains($so-border,'#')">
  172.                 <xsl:attribute name="w:color"><xsl:value-of select="substring-after($so-border, '#')"/></xsl:attribute>
  173.             </xsl:when>
  174.             <xsl:otherwise>
  175.                 <xsl:attribute name="w:color">auto</xsl:attribute>
  176.             </xsl:otherwise>
  177.         </xsl:choose>
  178.     </xsl:template>
  179. </xsl:stylesheet>
  180.